<?php

namespace app\merchant\model;

use think\Model;

/**
 * 资金明细
 */
class UserMoneyLog extends Model
{

    //设置当前模型对应的完整数据表名称
    protected $table = 'tp_user_moneylog';

    //收入类型
    CONST CATEGORY_INVESTOR_INCOME_RECHARGE = 1; //充值
    CONST CATEGORY_INVESTOR_INCOME_REPAYMENT = 2; //还款
    CONST CATEGORY_INVESTOR_INCOME_COMMSISSION = 3; //佣金
    CONST CATEGORY_INVESTOR_INCOME_REDPACKET = 4; //红包
    //支出类型
    CONST CATEGORY_INVESTOR_OUTLAY_WITHDRAW = 5; //提现
    CONST CATEGORY_INVESTOR_OUTLAY_INVEST = 6; //投标
    CONST CATEGORY_INVESTOR_OUTLAY_SERVICEFEE = 7; //服务费
    CONST CATEGORY_INVESTOR_INCOME_TRANSFER = 8;//转入
    CONST CATEGORY_INVESTOR_INCOME_REFUND = 9;//流标退款
    //资金状态
    CONST STATUS_SUCCESS = 1; //成功
    CONST STATUS_FAILED = 2; //失败
    CONST STATUS_PROCESSING = 3; //待处理
    CONST STATUS_WAIT_PROCESS = 4; //处理中

    /**
     * 获取操作类型列表
     * @return type
     */
    public static function getCategoryList()
    {
        $list = [
            self::CATEGORY_INVESTOR_INCOME_RECHARGE => '充值',
            self::CATEGORY_INVESTOR_INCOME_REPAYMENT => '还款',
            self::CATEGORY_INVESTOR_INCOME_COMMSISSION => '佣金',
            self::CATEGORY_INVESTOR_INCOME_REDPACKET => '红包',
            self::CATEGORY_INVESTOR_OUTLAY_WITHDRAW => '提现',
            self::CATEGORY_INVESTOR_OUTLAY_INVEST => '投标',
            self::CATEGORY_INVESTOR_OUTLAY_SERVICEFEE => '服务费',
            self::CATEGORY_INVESTOR_INCOME_TRANSFER => '转入',
            self::CATEGORY_INVESTOR_INCOME_REFUND => '流标退款',
        ];
        
        return $list;
    }
    
    /**
     * 获取操作类型名称
     * @param type $category 操作类型代码
     * @return string 操作类型名称
     */
    public static function getCategoryName($category)
    {
        $list = [
            self::CATEGORY_INVESTOR_INCOME_RECHARGE => '充值',
            self::CATEGORY_INVESTOR_INCOME_REPAYMENT => '还款',
            self::CATEGORY_INVESTOR_INCOME_COMMSISSION => '佣金',
            self::CATEGORY_INVESTOR_INCOME_REDPACKET => '红包',
            self::CATEGORY_INVESTOR_OUTLAY_WITHDRAW => '提现',
            self::CATEGORY_INVESTOR_OUTLAY_INVEST => '投标',
            self::CATEGORY_INVESTOR_OUTLAY_SERVICEFEE => '服务费',
            self::CATEGORY_INVESTOR_INCOME_TRANSFER => '转入',
            self::CATEGORY_INVESTOR_INCOME_REFUND => '流标退款',
        ];
        
        return isset($list[$category]) ? $list[$category] : '未知操作类型：' . $category;
    }
    
    /**
     * 获取状态列表
     * @return string
     */
    public static function getStatusList()
    {
        $list = [
            self::STATUS_SUCCESS => '成功',
            self::STATUS_FAILED => '失败',
            self::STATUS_PROCESSING => '待处理',
            self::STATUS_WAIT_PROCESS => '处理中',
        ];
        
        return $list;
    }
    
    /**
     * 获取状态名称
     * @param type $status 状态代码
     * @return type 状态名称
     */
    public static function getStatusName($status)
    {
        $list = [
            self::STATUS_SUCCESS => '成功',
            self::STATUS_FAILED => '失败',
            self::STATUS_PROCESSING => '待处理',
            self::STATUS_WAIT_PROCESS => '处理中',
        ];
        
        return isset($list[$status]) ? $list[$status] : '未知状态类型：' . $status;
    }

}
